<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<table border="1">
  <caption>个人信息</caption>
  <tr>
    <td>照片:</td>
    <td><img id="head_img" width="50px" src="../day05/head.jpg" alt=""></td>
  </tr>
  <tr>
    <td>名字:</td>
    <td id="name_td">xxx</td>
  </tr>
  <tr>
    <td>年龄:</td>
    <td id="age_td">xxx</td>
  </tr>
  <tr>
    <td>好友:</td>
    <td><ul id="friend_ul"></ul></td>
  </tr>
</table>
<input type="button" value="请求数据" onclick="f()">

<script>
  function f() {
    //模拟从服务器获取的数据
    let person ={name:"苍老师",age:50,url:"../c.jpeg",
    friend:["刘备","关羽","张飞"]}
    //获取页面中的元素对象
    let head_img = document.querySelector("#head_img");
    let name_td = document.querySelector("#name_td");
    let age_td = document.querySelector("#age_td");
    //把对象中的数据去除并赋值给页面中的元素对象
    head_img.src=person.url;
    name_td.innerText = person.name;
    age_td.innerText = person.age;
    //遍历好友数组
    for (const friendName of person.friend) {
      //创建li
      let li = document.createElement("li");
      li.innerText = friendName;
      //把li 添加到ul里面
      friend_ul.append(li);
    }
  }
</script>
</body>
</html>